﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Text;
using System.Data.Common;
using System.Data.SQLite;
using System.Configuration;
using System.IO;
using System.Data;

namespace Wusong.Dal.SQLLite
{
    public class SQLLiteDNet 
    {

        public DbConnection GetConn()
        {
            DbProviderFactory fact = DbProviderFactories.GetFactory("System.Data.SQLite");
            DbConnection cnn = fact.CreateConnection();
            cnn.ConnectionString = ConfigurationManager.ConnectionStrings["SQLLite"].ConnectionString;
            return cnn;
        }

        public object Insert(System.Data.DataRow dr)
        {
            StringBuilder commdSB = new StringBuilder();
            commdSB.Append("insert into ");
            commdSB.Append(dr.Table.TableName);
            commdSB.Append("( ");
            string[] names = new string[dr.Table.Columns.Count];
            for (int i = 0; i < names.Count(); i++)
            {
                names[i] = dr.Table.Columns[i].ColumnName;
            }

            commdSB.Append(string.Join(",",names));
            commdSB.Append(" )");

            return null;
        }

        public object Insert(System.Data.DataTable dt)
        {
            throw new NotImplementedException();
        }

        public object Insert(System.Data.DataSet ds)
        {
            throw new NotImplementedException();
        }

        public void Update(System.Data.DataRow dr)
        {
            throw new NotImplementedException();
        }

        public void Update(System.Data.DataTable dt)
        {
            throw new NotImplementedException();
        }

        public void Update(System.Data.DataSet ds)
        {
            throw new NotImplementedException();
        }

        public object Query(System.Data.IDbCommand command, IEnumerable<System.Data.IDbDataParameter> parms)
        {
            throw new NotImplementedException();
        }

        public static object AddParameter(string key,object value)
        {
            return new SQLiteParameter(key, value);
        }
    }
}
